cmake_minimum_required(VERSION 3.16)
project(cfg_ui)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
# set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)

# 手动列目录，可读性高，也能增量
set(DIRS
  dynamic_background
  ./sapid_switch
  ./linear_check_box
  ./ProgressBar
)

foreach(dir ${DIRS})
    file(GLOB_RECURSE tmp CONFIGURE_DEPENDS ${dir}/*.cpp ${dir}/*.h)
    list(APPEND SRCS ${tmp})
endforeach()

add_library(ui 
  STATIC
  ${SRCS}
)

set(ABS_DIRS)
foreach(d ${DIRS})
    list(APPEND ABS_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/${d}")
endforeach()

target_include_directories(ui PUBLIC ${ABS_DIRS})

target_link_libraries(ui
  PRIVATE 
  Qt${QT_VERSION_MAJOR}::Widgets)
